package cn.ibdsr.human.exception;

import cn.ibdsr.human.constant.GunsExceptionEnum;

/**
 * @description:
 * @author: cdl
 * @email: iamcimon@qq.com
 * @date: 2021/8/2 13:09
 */
public class GunsException extends RuntimeException {
    protected int friendlyCode;
    protected String friendlyMsg;
    protected String urlPath;

    protected GunsException(int friendlyCode, String friendlyMsg, String urlPath) {
        this.setValues(friendlyCode, friendlyMsg, urlPath);
    }

    public GunsException(Throwable throwable) {
        super(throwable);
    }

    public GunsException(GunsExceptionEnum bizExceptionEnum) {
        this.setValues(bizExceptionEnum.getCode(), bizExceptionEnum.getMessage(), bizExceptionEnum.getUrlPath());
    }

    public GunsException(GunsExceptionEnum bizExceptionEnum, String message) {
        this.setValues(bizExceptionEnum.getCode(), message, bizExceptionEnum.getUrlPath());
    }

    public GunsException(int code, String message) {
        this.friendlyCode = code;
        this.friendlyMsg = message;
    }

    private void setValues(int friendlyCode, String friendlyMsg, String urlPath) {
        this.friendlyCode = friendlyCode;
        this.friendlyMsg = friendlyMsg;
        this.urlPath = urlPath;
    }

    public int getCode() {
        return this.friendlyCode;
    }

    public void setCode(int code) {
        this.friendlyCode = code;
    }

    public String getMessage() {
        return this.friendlyMsg;
    }

    public void setMessage(String message) {
        this.friendlyMsg = message;
    }

    public String getUrlPath() {
        return this.urlPath;
    }

    public void setUrlPath(String urlPath) {
        this.urlPath = urlPath;
    }
}
